<template>
	<view class="community">
		<view class="head_bg" style="position: relative;"></view>
		<view class="big_box" style="top: -220rpx;padding-top: 30rpx;">
			<view class="equ_list">
				<view class="ele_title" style="padding-top: 20rpx;">
					<view class="ele_title_left">
						<view class="ele_title_inner">{{info.residential_quarters_name}}</view>
						<view class="ele_address">
							<text>小区地址：{{info.residential_quarters_address}}</text>
						</view>
					</view>
					<view class="falt_status" v-if="info.processing_status==0">未处理</view>
					<view class="falt_status" v-if="info.processing_status==1">已处理</view>
				</view>
				<view class="equ_list_inner">
					<view class="equ_list_inner_text">上报人:{{info.user_phone_number}}</view>
					<view class="equ_list_inner_text">终端编号：{{info.equipment_number}}</view>
					<view class="equ_list_inner_text" v-if="info.fault_type==0">故障类型：二维码损坏</view>
					<view class="equ_list_inner_text" v-if="info.fault_type==1">故障类型：插座损坏</view>
					<view class="equ_list_inner_text" v-if="info.fault_type==2">故障类型：插座没电</view>
					<view class="equ_list_inner_text" v-if="info.fault_type==3">故障类型：其他</view>
					<view class="equ_list_inner_text">上报时间：{{info.failure_time}}</view>
					<view class="equ_list_inner_text">问题描述：
					<text style="color: #EC692F;">{{info.cause_of_failure}}</text></view>
				</view>
			</view>
			<view class="equ_list">
				<view class="ele_title" style="padding-top: 20rpx;padding-bottom: 15rpx;">
					<view class="ele_title_left">
						<view class="ele_title_inner">处理信息</view>
					</view>
				</view>
				<view class="equ_list_inner">
					<view class="falt_detail_box">
						<textarea v-model="cljg" class="falt_detail_area" placeholder="处理结果" />
					</view>
				</view>
			</view>
			
		</view>
		<view class="foot">
		   <button type="button" class="cu-btn block bg-blue lg" @tap="toAdd()">提交</button>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				id:0,
				info:'',
				cljg:''
			}
		},
		onLoad(options) {
			this.id=options.id
		},
		onShow() {
			this.getInfo();
		},
		methods: {
			getInfo(){
				let that=this;
				that.http.tokenreq({
					url: 'fault/v1/getinfo',
					data: {
				    "id":this.id,
					}
				}).then((res) => {
					let e=res.data;
					console.log(e)
					if(e.code==0 && e.success){
						this.info = e.data;
					}else{
						uni.showModal({
							content:e.message,
							showCancel:false,
						})
					}
				})
			},
			toAdd(){
				if(!this.cljg){
					uni.showToast({
						icon: 'none',
					    title: '处理结果不能为空'
					});
					return;
				}
				let that=this;
				that.http.tokenreq({
					url: 'fault/v1/handle',
					data:{
						"id":this.id,
						"processing_results":this.cljg
					}
				}).then((res) => {
					console.log("res="+JSON.stringify(res));
					let e=res.data;
					if(e.code==0 && e.success){
						uni.showModal({
							content: e.message,
							showCancel:false,
							success: function (res) {
								if (res.confirm) {
									uni.navigateTo({
										url:'/pages/breakdown/faultInformation/faultInformation'
									})
								}
							}
						});
					}else{
						uni.showToast({
							icon: 'none',
						    title: e.message
						});
					}
				})
			}
		}
	}
</script>
<style>
	.foot{
		position: fixed;
		left: 0;
		bottom: 0;
		width:100%;
	}
</style>